#include <stdlib.h>

#include "nolock_queue.h"

#ifdef __cplusplus
extern "C" {
#endif

queue_nolock_t *queue_nolock_create(const uint16_t size)
{
    return ringbuffer_create(size * sizeof(void *));
}

void queue_nolock_destroy(queue_nolock_t *queue)
{
    ringbuffer_destroy(queue);
}

int queue_nolock_empty(queue_nolock_t *queue)
{
    return ringbuffer_empty(queue);
}

int queue_nolock_full(queue_nolock_t *queue)
{
    return ringbuffer_full(queue);
}

int queue_nolock_size(queue_nolock_t *queue)
{
    return ringbuffer_used(queue) / sizeof(void *);
}

void queue_nolock_clear(queue_nolock_t *queue)
{
    ringbuffer_clear(queue);
}

int queue_nolock_push(queue_nolock_t *queue, void *item)
{
    return (sizeof(void *) != ringbuffer_put(queue, (uint8_t *)&item, sizeof(void *))) ? -1 : 0;
}

void *queue_nolock_pop(queue_nolock_t *queue)
{
    void *pointer = NULL;
    if(sizeof(void *) != ringbuffer_get(queue, (uint8_t *)&pointer, sizeof(void *)))
        return NULL;
    return pointer;
}

#ifdef __cplusplus
}
#endif
